package com.hemaapp.yjnh.bean;

import com.android.uu.utils.uuUtils;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import xtom.frame.XtomObject;
import xtom.frame.exception.DataParseException;

/**
 * 类描述：田家的定制订单
 * 创建人：GuiyouZhang
 * 创建时间：2016/9/5 16:14
 * 修改备注：
 */
public class FarmerCustomOrder extends XtomObject implements Serializable {

    /**
     * id : 1893
     * bill_sn : 201609051205212370
     * client_id : 515
     * pay_client_id : null
     * keytype : 2
     * confirmtype : 0
     * payflag : 4
     * other_payflag : 0
     * tradetype : 1
     * sendflag : 0
     * statetype : 1
     * returnflag : 0
     * consignee : 美国
     * phone : 18800000013
     * address : 安徽省安庆市枞阳县很详细的地址
     * personal_id : null
     * zipcode : 258888
     * goods_fee : 2.0000
     * addition_fee : 1.2000
     * shipping_fee : null
     * total_fee : 3.2000
     * score_fee : 1.0000
     * costcode : null
     * memo : 无
     * shipping_name : null
     * shipping_num : null
     * startdate : null
     * regdate : 2016-09-05 12:05:21
     * buydate : 2016-09-05 12:05:38
     * senddate : null
     * recvdate : null
     * expect_senddate : 2016-11-01
     * farmer_id : 548
     * childItems : [{"id":"1980","bill_id":"1893","client_id":"515","blog_id":"40","specid":"0","addition_ids":"190","addition_fee":"1.2000","reply_id":"0","name":"201608241109","price":"2.0000","score":"1.0000","score_percent":"0","buycount":"1","expressfee":"0.00","shipping_fee":"0.00","itemtype":"0","confirmtype":"0","servicetype":"0","replytype":"0","regdate":"2016-09-05 12:05:21","applydate":null,"reason":null,"description":null,"handledate":null,"memo":null,"shipping_name":null,"shipping_num":null,"imgurl0":null,"imgurl0big":null,"imgurl1":null,"imgurl1big":null,"imgurl2":null,"imgurl2big":null,"imgurl3":null,"imgurl3big":null,"one_spec":"","two_spec":"","one_specname":"","two_specname":"","blog_returnflag":"0","imgurl":"http://124.128.23.74:8008/group8/hm_yjnh/uploadfiles/2016/09/201609051108128570_thumb.jpg","imgurlbig":"http://124.128.23.74:8008/group8/hm_yjnh/uploadfiles/2016/09/201609051108128570.jpg","good_unit":"公斤"}]
     * additionItems : [{"id":"190","good_id":"40","content":"包装费","price":"1.2000","removeflag":"0","regdate":"2016-09-05 11:32:39"}]
     */

    private String id;
    private String bill_sn;
    private String client_id;
    private String pay_client_id;
    private String keytype;
    private String confirmtype;
    private String payflag;
    private String other_payflag;
    private String tradetype;
    private String sendflag;
    private String statetype;
    private String returnflag;
    private String consignee;
    private String phone;
    private String address;
    private String personal_id;
    private String zipcode;
    private String goods_fee;
    private String addition_fee;
    private String shipping_fee;
    private String total_fee;
    private String score_fee;
    private String costcode;
    private String memo;
    private String shipping_name;
    private String shipping_num;
    private String startdate;
    private String regdate;
    private String buydate;
    private String senddate;
    private String recvdate;
    private String expect_senddate;
    private String farmer_id;
    private String childStr;
    private String additionStr;
    /**
     * id : 1980
     * bill_id : 1893
     * client_id : 515
     * blog_id : 40
     * specid : 0
     * addition_ids : 190
     * addition_fee : 1.2000
     * reply_id : 0
     * name : 201608241109
     * price : 2.0000
     * score : 1.0000
     * score_percent : 0
     * buycount : 1
     * expressfee : 0.00
     * shipping_fee : 0.00
     * itemtype : 0
     * confirmtype : 0
     * servicetype : 0
     * replytype : 0
     * regdate : 2016-09-05 12:05:21
     * applydate : null
     * reason : null
     * description : null
     * handledate : null
     * memo : null
     * shipping_name : null
     * shipping_num : null
     * imgurl0 : null
     * imgurl0big : null
     * imgurl1 : null
     * imgurl1big : null
     * imgurl2 : null
     * imgurl2big : null
     * imgurl3 : null
     * imgurl3big : null
     * one_spec :
     * two_spec :
     * one_specname :
     * two_specname :
     * blog_returnflag : 0
     * imgurl : http://124.128.23.74:8008/group8/hm_yjnh/uploadfiles/2016/09/201609051108128570_thumb.jpg
     * imgurlbig : http://124.128.23.74:8008/group8/hm_yjnh/uploadfiles/2016/09/201609051108128570.jpg
     * good_unit : 公斤
     */

    private ArrayList<ChildItemsBean> childItems = new ArrayList<>();
    /**
     * id : 190
     * good_id : 40
     * content : 包装费
     * price : 1.2000
     * removeflag : 0
     * regdate : 2016-09-05 11:32:39
     */

    private ArrayList<AdditionItemsBean> additionItems = new ArrayList<>();

    public FarmerCustomOrder(JSONObject jsonObject) throws DataParseException {
        if (jsonObject != null) {
            try {
                id = get(jsonObject, "id");
                bill_sn = get(jsonObject, "bill_sn");
                client_id = get(jsonObject, "client_id");
                pay_client_id = get(jsonObject, "pay_client_id");
                keytype = get(jsonObject, "keytype");
                confirmtype = get(jsonObject, "confirmtype");
                payflag = get(jsonObject, "payflag");
                other_payflag = get(jsonObject, "other_payflag");
                tradetype = get(jsonObject, "tradetype");
                sendflag = get(jsonObject, "sendflag");
                statetype = get(jsonObject, "statetype");
                returnflag = get(jsonObject, "returnflag");
                consignee = get(jsonObject, "consignee");
                phone = get(jsonObject, "phone");
                address = get(jsonObject, "address");
                personal_id = get(jsonObject, "personal_id");
                zipcode = get(jsonObject, "zipcode");
                goods_fee = uuUtils.formatAfterDot2(get(jsonObject, "goods_fee"));
                addition_fee = uuUtils.formatAfterDot2(get(jsonObject, "addition_fee"));
                shipping_fee = uuUtils.formatAfterDot2(get(jsonObject, "shipping_fee"));
                total_fee = uuUtils.formatAfterDot2(get(jsonObject, "total_fee"));
                score_fee = uuUtils.formatAfterDot2(get(jsonObject, "score_fee"));
                costcode = get(jsonObject, "costcode");
                memo = get(jsonObject, "memo");
                shipping_name = get(jsonObject, "shipping_name");
                shipping_num = get(jsonObject, "shipping_num");
                startdate = get(jsonObject, "startdate");
                regdate = get(jsonObject, "regdate");
                buydate = get(jsonObject, "buydate");
                senddate = get(jsonObject, "senddate");
                recvdate = get(jsonObject, "recvdate");
                expect_senddate = get(jsonObject, "expect_senddate");
                farmer_id = get(jsonObject, "farmer_id");
                childStr = get(jsonObject, "childItems");
                additionStr = get(jsonObject, "additionItems");

                if (!isNull(childStr)) {
                    JSONArray jsons = new JSONArray(childStr);
                    for (int i = 0; i < jsons.length(); i++) {
                        JSONObject child = jsons.getJSONObject(i);
                        childItems.add(new Gson().fromJson(child.toString(), ChildItemsBean.class));
                    }
                }

                if (!isNull(additionStr)) {
                    JSONArray jsons = new JSONArray(additionStr);
                    for (int i = 0; i < jsons.length(); i++) {
                        JSONObject child = jsons.getJSONObject(i);
                        additionItems.add(new Gson().fromJson(child.toString(), AdditionItemsBean.class));
                    }
                }
            } catch (JSONException e) {
                throw new DataParseException(e);
            }
        }

    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getBill_sn() {
        return bill_sn;
    }

    public void setBill_sn(String bill_sn) {
        this.bill_sn = bill_sn;
    }

    public String getClient_id() {
        return client_id;
    }

    public void setClient_id(String client_id) {
        this.client_id = client_id;
    }

    public String getPay_client_id() {
        return pay_client_id;
    }

    public void setPay_client_id(String pay_client_id) {
        this.pay_client_id = pay_client_id;
    }

    public String getKeytype() {
        return keytype;
    }

    public void setKeytype(String keytype) {
        this.keytype = keytype;
    }

    public String getConfirmtype() {
        return confirmtype;
    }

    public void setConfirmtype(String confirmtype) {
        this.confirmtype = confirmtype;
    }

    public String getPayflag() {
        return payflag;
    }

    public void setPayflag(String payflag) {
        this.payflag = payflag;
    }

    public String getOther_payflag() {
        return other_payflag;
    }

    public void setOther_payflag(String other_payflag) {
        this.other_payflag = other_payflag;
    }

    public String getTradetype() {
        return tradetype;
    }

    public void setTradetype(String tradetype) {
        this.tradetype = tradetype;
    }

    public String getSendflag() {
        return sendflag;
    }

    public void setSendflag(String sendflag) {
        this.sendflag = sendflag;
    }

    public String getStatetype() {
        return statetype;
    }

    public void setStatetype(String statetype) {
        this.statetype = statetype;
    }

    public String getReturnflag() {
        return returnflag;
    }

    public void setReturnflag(String returnflag) {
        this.returnflag = returnflag;
    }

    public String getConsignee() {
        return consignee;
    }

    public void setConsignee(String consignee) {
        this.consignee = consignee;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPersonal_id() {
        return personal_id;
    }

    public void setPersonal_id(String personal_id) {
        this.personal_id = personal_id;
    }

    public String getZipcode() {
        return zipcode;
    }

    public void setZipcode(String zipcode) {
        this.zipcode = zipcode;
    }

    public String getGoods_fee() {
        return goods_fee;
    }

    public void setGoods_fee(String goods_fee) {
        this.goods_fee = goods_fee;
    }

    public String getAddition_fee() {
        return addition_fee;
    }

    public void setAddition_fee(String addition_fee) {
        this.addition_fee = addition_fee;
    }

    public String getShipping_fee() {
        return shipping_fee;
    }

    public void setShipping_fee(String shipping_fee) {
        this.shipping_fee = shipping_fee;
    }

    public String getTotal_fee() {
        return total_fee;
    }

    public void setTotal_fee(String total_fee) {
        this.total_fee = total_fee;
    }

    public String getScore_fee() {
        return score_fee;
    }

    public void setScore_fee(String score_fee) {
        this.score_fee = score_fee;
    }

    public String getCostcode() {
        return costcode;
    }

    public void setCostcode(String costcode) {
        this.costcode = costcode;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public String getShipping_name() {
        return shipping_name;
    }

    public void setShipping_name(String shipping_name) {
        this.shipping_name = shipping_name;
    }

    public String getShipping_num() {
        return shipping_num;
    }

    public void setShipping_num(String shipping_num) {
        this.shipping_num = shipping_num;
    }

    public String getStartdate() {
        return startdate;
    }

    public void setStartdate(String startdate) {
        this.startdate = startdate;
    }

    public String getRegdate() {
        return regdate;
    }

    public void setRegdate(String regdate) {
        this.regdate = regdate;
    }

    public String getBuydate() {
        return buydate;
    }

    public void setBuydate(String buydate) {
        this.buydate = buydate;
    }

    public String getSenddate() {
        return senddate;
    }

    public void setSenddate(String senddate) {
        this.senddate = senddate;
    }

    public String getRecvdate() {
        return recvdate;
    }

    public void setRecvdate(String recvdate) {
        this.recvdate = recvdate;
    }

    public String getExpect_senddate() {
        return expect_senddate;
    }

    public void setExpect_senddate(String expect_senddate) {
        this.expect_senddate = expect_senddate;
    }

    public String getFarmer_id() {
        return farmer_id;
    }

    public void setFarmer_id(String farmer_id) {
        this.farmer_id = farmer_id;
    }

    public ArrayList<ChildItemsBean> getChildItems() {
        return childItems;
    }

    public ArrayList<AdditionItemsBean> getAdditionItems() {
        return additionItems;
    }

    public static class ChildItemsBean implements Serializable {
        private String id;
        private String bill_id;
        private String client_id;
        private String blog_id;
        private String specid;
        private String addition_ids;
        private String addition_fee;
        private String reply_id;
        private String name;
        private String price;
        private String score;
        private String score_percent;
        private String buycount;
        private String expressfee;
        private String shipping_fee;
        private String itemtype;
        private String confirmtype;
        private String servicetype;
        private String replytype;
        private String regdate;
        private String applydate;
        private String reason;
        private String description;
        private String handledate;
        private String memo;
        private String shipping_name;
        private String shipping_num;
        private String imgurl0;
        private String imgurl0big;
        private String imgurl1;
        private String imgurl1big;
        private String imgurl2;
        private String imgurl2big;
        private String imgurl3;
        private String imgurl3big;
        private String one_spec;
        private String two_spec;
        private String one_specname;
        private String two_specname;
        private String blog_returnflag;
        private String imgurl;
        private String imgurlbig;
        private String good_unit;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getBill_id() {
            return bill_id;
        }

        public void setBill_id(String bill_id) {
            this.bill_id = bill_id;
        }

        public String getClient_id() {
            return client_id;
        }

        public void setClient_id(String client_id) {
            this.client_id = client_id;
        }

        public String getBlog_id() {
            return blog_id;
        }

        public void setBlog_id(String blog_id) {
            this.blog_id = blog_id;
        }

        public String getSpecid() {
            return specid;
        }

        public void setSpecid(String specid) {
            this.specid = specid;
        }

        public String getAddition_ids() {
            return addition_ids;
        }

        public void setAddition_ids(String addition_ids) {
            this.addition_ids = addition_ids;
        }

        public String getAddition_fee() {
            return addition_fee;
        }

        public void setAddition_fee(String addition_fee) {
            this.addition_fee = uuUtils.formatAfterDot2(addition_fee);
        }

        public String getReply_id() {
            return reply_id;
        }

        public void setReply_id(String reply_id) {
            this.reply_id = reply_id;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = uuUtils.formatAfterDot2(price);
        }

        public String getScore() {
            return score;
        }

        public void setScore(String score) {
            this.score = score;
        }

        public String getScore_percent() {
            return score_percent;
        }

        public void setScore_percent(String score_percent) {
            this.score_percent = score_percent;
        }

        public String getBuycount() {
            return buycount;
        }

        public void setBuycount(String buycount) {
            this.buycount = buycount;
        }

        public String getExpressfee() {
            return expressfee;
        }

        public void setExpressfee(String expressfee) {
            this.expressfee = uuUtils.formatAfterDot2(expressfee);
        }

        public String getShipping_fee() {
            return shipping_fee;
        }

        public void setShipping_fee(String shipping_fee) {
            this.shipping_fee = uuUtils.formatAfterDot2(shipping_fee);
        }

        public String getItemtype() {
            return itemtype;
        }

        public void setItemtype(String itemtype) {
            this.itemtype = itemtype;
        }

        public String getConfirmtype() {
            return confirmtype;
        }

        public void setConfirmtype(String confirmtype) {
            this.confirmtype = confirmtype;
        }

        public String getServicetype() {
            return servicetype;
        }

        public void setServicetype(String servicetype) {
            this.servicetype = servicetype;
        }

        public String getReplytype() {
            return replytype;
        }

        public void setReplytype(String replytype) {
            this.replytype = replytype;
        }

        public String getRegdate() {
            return regdate;
        }

        public void setRegdate(String regdate) {
            this.regdate = regdate;
        }

        public String getApplydate() {
            return applydate;
        }

        public void setApplydate(String applydate) {
            this.applydate = applydate;
        }

        public String getReason() {
            return reason;
        }

        public void setReason(String reason) {
            this.reason = reason;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        public String getHandledate() {
            return handledate;
        }

        public void setHandledate(String handledate) {
            this.handledate = handledate;
        }

        public String getMemo() {
            return memo;
        }

        public void setMemo(String memo) {
            this.memo = memo;
        }

        public String getShipping_name() {
            return shipping_name;
        }

        public void setShipping_name(String shipping_name) {
            this.shipping_name = shipping_name;
        }

        public String getShipping_num() {
            return shipping_num;
        }

        public void setShipping_num(String shipping_num) {
            this.shipping_num = shipping_num;
        }

        public String getImgurl0() {
            return imgurl0;
        }

        public void setImgurl0(String imgurl0) {
            this.imgurl0 = imgurl0;
        }

        public String getImgurl0big() {
            return imgurl0big;
        }

        public void setImgurl0big(String imgurl0big) {
            this.imgurl0big = imgurl0big;
        }

        public String getImgurl1() {
            return imgurl1;
        }

        public void setImgurl1(String imgurl1) {
            this.imgurl1 = imgurl1;
        }

        public String getImgurl1big() {
            return imgurl1big;
        }

        public void setImgurl1big(String imgurl1big) {
            this.imgurl1big = imgurl1big;
        }

        public String getImgurl2() {
            return imgurl2;
        }

        public void setImgurl2(String imgurl2) {
            this.imgurl2 = imgurl2;
        }

        public String getImgurl2big() {
            return imgurl2big;
        }

        public void setImgurl2big(String imgurl2big) {
            this.imgurl2big = imgurl2big;
        }

        public String getImgurl3() {
            return imgurl3;
        }

        public void setImgurl3(String imgurl3) {
            this.imgurl3 = imgurl3;
        }

        public String getImgurl3big() {
            return imgurl3big;
        }

        public void setImgurl3big(String imgurl3big) {
            this.imgurl3big = imgurl3big;
        }

        public String getOne_spec() {
            return one_spec;
        }

        public void setOne_spec(String one_spec) {
            this.one_spec = one_spec;
        }

        public String getTwo_spec() {
            return two_spec;
        }

        public void setTwo_spec(String two_spec) {
            this.two_spec = two_spec;
        }

        public String getOne_specname() {
            return one_specname;
        }

        public void setOne_specname(String one_specname) {
            this.one_specname = one_specname;
        }

        public String getTwo_specname() {
            return two_specname;
        }

        public void setTwo_specname(String two_specname) {
            this.two_specname = two_specname;
        }

        public String getBlog_returnflag() {
            return blog_returnflag;
        }

        public void setBlog_returnflag(String blog_returnflag) {
            this.blog_returnflag = blog_returnflag;
        }

        public String getImgurl() {
            return imgurl;
        }

        public void setImgurl(String imgurl) {
            this.imgurl = imgurl;
        }

        public String getImgurlbig() {
            return imgurlbig;
        }

        public void setImgurlbig(String imgurlbig) {
            this.imgurlbig = imgurlbig;
        }

        public String getGood_unit() {
            return good_unit;
        }

        public void setGood_unit(String good_unit) {
            this.good_unit = good_unit;
        }
    }

    public static class AdditionItemsBean implements Serializable {
        private String id;
        private String good_id;
        private String content;
        private String price;
        private String removeflag;
        private String regdate;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getGood_id() {
            return good_id;
        }

        public void setGood_id(String good_id) {
            this.good_id = good_id;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = uuUtils.formatAfterDot2(price);
        }

        public String getRemoveflag() {
            return removeflag;
        }

        public void setRemoveflag(String removeflag) {
            this.removeflag = removeflag;
        }

        public String getRegdate() {
            return regdate;
        }

        public void setRegdate(String regdate) {
            this.regdate = regdate;
        }
    }
}
